<?php
    #-------------------------------------------------------------#
	# This file is part of the Kumomado - Virtual Window Platform #
	# for PHP. (c) 2009 Tsai, Min Che <tirme0812@gmail.com>       #
	# Please visit http://www.kumomado.org/ for more information. #
	#                                                             #
	# This software is licensed under the GNU License v3. Please  #
	# view the LICENSE file for the full text of this license.    #
    #-------------------------------------------------------------#

	Kumomado::load('Application.Controller.KumomadoApplicationController');
	/**
	 * @package applications
	 * @subpackage member
	 * @author Tsai, Min Che
	 */
	class MemberUserController extends KumomadoApplicationController {
		/**
		 * 
		 * @param array $params
		 */
		public function Action_CheckUserLogin($params) {
			$login = false;
			$error_msg = '';
			$lang = Kumomado::lang('main');
			if (trim($params['user_account']) == '') {
				$error_msg = $lang->AccountEmpty;
			}
			if (trim($params['user_password']) == '') {
				$error_msg = $lang->PasswordEmpty;
			}
			$user = $this->model->userLogin($params['user_account'], $params['user_password']);
			if ($user->user_id > 0) {
				$_SESSION['user'] = $user->user_id;
				$login = true;
			}
			if (false == $login) {
				$error_msg = $lang->LoginFailed;
			}			
			$this->view->response('UserLogin', $login);
			$this->view->response('UserLoginErrorMsg', $error_msg);
			$this->view->userLogin();
		}
		/**
		 * 
		 * @param array $params
		 */
		public function userManage($params) {
			$this->view->userManage();
		}
	}
?>